﻿using FrameWorkCore.NewtonsoftJson;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FrameWorkCore
{
    public static class NewtonsoftJsonService
    {
        public static void ConfigureNewtonsoftJson(this IMvcBuilder services)
        {
            services.AddNewtonsoftJson(
                options =>
                 {

                     options.SerializerSettings.ContractResolver = new NullToEmptyStringResolver();
                     
                     options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
                     
                     options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss";

                     //options.SerializerSettings.DefaultValueHandling = DefaultValueHandling.Ignore;

                });
        }
    }
}
